package cn.edu.uestc.software.controller;

import cn.edu.uestc.software.pojo.Role;
import cn.edu.uestc.software.service.RoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Resource
    private RoleService roleService;

    @RequestMapping(value = "/selectRoles",method = RequestMethod.GET)
    public Map<String,Object> selectRoles(@RequestParam int page,
                                          String roleName,
                                          String roleLevel){

        return roleService.selectRoles(page,roleName,roleLevel);
    }

    @RequestMapping(value = "/selectAllRoles",method = RequestMethod.GET)
    public Map<String,Object> selectAllRoles(){

        return roleService.selectAllRoles();
    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Map<String,Object> insert(@RequestBody Role role){

        return roleService.insert(role);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody Role role){

        return roleService.update(role);
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public Map<String,Object> delete(@RequestParam Integer id){

        return roleService.delete(id);
    }
}

















